Skip to main content

Web Service publication framework

Introduction

The Service publication framework is dedicated to response to one need: how set in relation a inbound request with the applicative method which can response to it.

The framework is based on two key concepts:

  • Routing: it read the request url and choose the method to invoke to resolve the request.
  • Serialization/Deserialization: it allow to invoke a method by transforming the request bytes into binary format usable by the method, and reciprocally.

When a client request enter in the system:

  1. the request object is filled with inbound bytes
  2. the router use the request url to define an execution stack
  3. the execution stack is called on the request object and return a response object,
  4. the content of response object is send to the client

Configuration

To run the server for testing you can run the command:

ewamservice.exe /RUNASSERVICE:(wyde-admin)/myApp.json /RUNASSERVICE.PORT:9944

You have to create a file myApp.json in your Admin folder, with the following schema:

For exemple to declare a service with class `aCustomServiceClass1' in a stateless session, you can fill with content:

/Admin/myApp.json
{
"runtimeMode": "Application",
"sessions": {
"stateless": {
"type": "stateless",
"services": [
{
"className": "aCustomServiceClass1"
}
]
}
}
}

Execution stack

The execution stack is a list of service middlewares with a service method at top.

When a execution stack is called on a request object, the method Execute is called on the first item, which will call the next item, and so on until the request reach the service method.

Routing

The routing is based on a feature tree similar to a filesystem (with method instead of file).

The feature tree is populated with objects named services. A service is a object which provide a InitService method which can be invoked by the router to install features of this service under the service path.

What are the features of a service, there is two kind of feature:

  • service method: a function which respond to the request
  • service middleware: a function which provide support arround the request, exemple: cookie parsing, authorization checking, logging, ...

Service Middleware

A service middleware is similar to a service method, but it's not the goal of the request, it's a intermediate method,

Service Method

Overriding of services

The services system is based on classes so to override a service feature we simply override the class methods. And ask to the system to used the child class instead of the mother.

For mapping overriding, we can simply override the InitService method.